package com.lenovo.codestatreport.git.controller;

import com.lenovo.codestatreport.git.service.CodeStatOnlyMasterService;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author Howie Lu
 * @version Updated at 2019/06/03
 * @description 统计仅master分支业务控制器
 */
@Controller
@RequestMapping("/codestat/only_master")
public class CodeStatOnlyMasterController {
    @Autowired
    CodeStatOnlyMasterService codeStatOnlyMasterService;

    /**
     * git代码统计的核心控制器，通过时间段和端别返回不同的统计信息
     *
     * @param request http请求
     * @return 自定义的List<Map<String, Object>>形式的仿json数据
     */
    @RequestMapping("/getStatsByDepartmentByTime")
    @ResponseBody
    List<Map<String, Object>> getStatsByDepartmentByTime(HttpServletRequest request) {
        String start = request.getParameter("start");
        String end = request.getParameter("end");
        String department = request.getParameter("department");
        return codeStatOnlyMasterService.getStatsByDepartmentByTime(start, end, department);
    }
}
